// 创建vue对象
var vm = new Vue({
    el: "#updateBook",
    data(){
        return{
            book: null,
            v_bookID: null,
            v_bookName: null,
            v_bookCounts: null,
            v_detail: null
        }
    },
    mounted(){
        var id = window.sessionStorage.getItem("id");
        axios.get("/books/find_by_id/" + id)
            .then(resp => {
                this.book = resp.data
                this.v_bookID = this.book.bookID
            })
            .catch(error => console.log(error))
    },
    methods: {
        updateBook(id){
            // 发起请求
            axios.post("/books/update", {
                bookID: this.v_bookID,
                bookName: this.v_bookName,
                bookCounts: this.v_bookCounts,
                detail: this.v_detail
            })
                .then(resp => {
                    window.location.href="/books/allBook.html"
                })
                .catch(error => (console.log(error)))
        }
    }
});